package com.application.Activity;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.application.Controller.ActivityController;
import com.application.Controller.NetworkController;
import com.application.Controller.ReadWriteFileController;


public class frmViewLogFile extends Activity{
	Handler mHandler;
	Runnable mUpdateResults;
	static ListView listviewLog;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_view_log_file);
		Log.d("Phu", "frmViewLogFile onCreate");
		listviewLog = (ListView)findViewById(R.id.lvLogFile);

		
		String tenNhom = NetworkController.getGroupName();
		Log.d("Phu", "ten nhom 2....: "+ tenNhom);
		String path = ReadWriteFileController.DIRECTORY + tenNhom+"LogList.xml";
		
		final ArrayList<String> arraylist = new ArrayList<String>();
		final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arraylist);
		
		listviewLog.setAdapter(listAdapter);
		
		ArrayList<String> LogList = ReadWriteFileController.readLogFile(getBaseContext(), path);
		
		for (String log : LogList){
			arraylist.add(log);
		}
		listAdapter.notifyDataSetChanged();	
		
		//up rồi tại sao ko được vậy nè, thiệt là .....haizzzz
		
		
	}
	
	@Override
	public void onStart(){
		super.onStart();
		ActivityController.setPeerActivity(this);
	}
	@Override
	public void onResume(){
		super.onResume();
		ActivityController.setPeerActivity(this);
	}
	@Override
	public void onPause(){
		super.onPause();
		ActivityController.setPeerActivity(this);
	} 
}
